package com.fy.fyspace.common.auth.authenum;

import lombok.Getter;

/**
 * 空间用户权限枚举
 */
@Getter
public enum SpaceUserPermissionEnum {
    
    SPACE_MANAGE(1001L, "SPACE_MANAGE", "空间管理权限"),
    MEMBER_MANAGE(1002L, "MEMBER_MANAGE", "成员管理权限"),
    PICTURE_UPLOAD(1003L, "PICTURE_UPLOAD", "图片上传权限"),
    PICTURE_DELETE(1004L, "PICTURE_DELETE", "图片删除权限"),
    PICTURE_VIEW(1005L, "PICTURE_VIEW", "图片查看权限"),
    PICTURE_EDIT(1006L, "PICTURE_EDIT", "图片编辑权限"),
    AI_GENERATE(1007L, "AI_GENERATE", "AI资源权限");

    /**
     * 权限id
     */
    private final Long permissionId;
    
    /**
     * 权限编码
     */
    private final String permissionCode;
    
    /**
     * 权限描述
     */
    private final String description;

    SpaceUserPermissionEnum(Long permissionId, String permissionCode, String description) {
        this.permissionId = permissionId;
        this.permissionCode = permissionCode;
        this.description = description;
    }

    /**
     * 根据权限编码获取权限枚举
     */
    public static SpaceUserPermissionEnum getByCode(String code) {
        for (SpaceUserPermissionEnum permission : values()) {
            if (permission.getPermissionCode().equals(code)) {
                return permission;
            }
        }
        return null;
    }
}